#!/bin/bash

# 设置环境
cd /root/ros2_space
source install/setup.bash

echo "Testing sensor node..."

# 启动sensor节点
echo "Starting sensor node..."
ros2 run robotone sensor_node &
SENSOR_PID=$!

# 等待节点启动
sleep 3

# 检查节点是否在运行
echo "Checking if node is running..."
ros2 node list

# 检查主题
echo "Checking topics..."
ros2 topic list

# 监听消息5秒
echo "Listening to sensor_data topic for 5 seconds..."
timeout 5 ros2 topic echo /sensor_data

# 停止节点
echo "Stopping sensor node..."
kill $SENSOR_PID

echo "Test completed."
